import React, { memo } from 'react'
import Acpm from './cpm/Acpm'
import { useDispatch, useSelector, shallowEqual } from 'react-redux'
import { addCount } from '@/store/modules/home'
import store from '@/store'
interface Iprops {
  children?: React.ReactNode
}
// store类型
type Istate = ReturnType<typeof store.getState>

const Discover: React.FC<Iprops> = () => {
  console.log('a组件刷新了')
  const $dispatch = useDispatch()

  const { name } = useSelector((store: Istate) => {
    return {
      name: store.home.name
    }
  })

  const btnHandle = () => {
    $dispatch(addCount(1))
  }

  return (
    <div>
      <div>discover页面</div>
      <div>
        home-store: {name}
        <button onClick={btnHandle}>+1</button>
      </div>
      <Acpm p1="p1" p2="p2" style={{ color: 'red' }} />
    </div>
  )
}

export default memo(Discover)
